﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using Fluid.Controls;
using System.Drawing;
using TouchRC.Logic;

namespace TouchRC.ListBoxes
{
    public class TransparentListBox : FluidListBox
    {
        private int m_MaxHeightFromBottom = 0;
        public int HeightMargin { get; set; }

        public Rectangle Bounds
        {
            get { return base.Bounds; }
            set
            {
                m_MaxHeightFromBottom = AppSettings.ScreenResolution.Height - UnscaleY(value.Y + value.Height);
                Rectangle newRect = new Rectangle(value.X, value.Y, value.Width, base.Height);
                base.Bounds = newRect;
                UpdateHeight();
            }
        }

        protected void UpdateHeight()
        {
            int height = (ItemCount * ScaledItemHeight) + ScaleY(HeightMargin);
            int maxHeight = ScaleY(AppSettings.ScreenResolution.Height) - (ScaleY(m_MaxHeightFromBottom) + Bounds.Y);
            if (height > maxHeight)
                height = maxHeight;
            base.Height = height;
            Invalidate();
        }

        protected override void InitControl()
        {
            base.InitControl();

        }
    }
}
